package com.hg.chapter862.repository;

import com.hg.chapter862.entity.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

@Repository
public class PersonRepository {

    @Autowired
    StringRedisTemplate stringRedisTemplate;

    @Resource
    ValueOperations<String, String> valOpsStr;

    @Autowired
    RedisTemplate<Object, Object> redisTemplate;

    @Resource
    ValueOperations<Object, Object> valOps;

    public void set(String key, String val) {
        valOpsStr.set(key, val);
    }

    public void save(Person person) {
        valOps.set(person.getId(), person);
    }
}
